﻿<UserControl x:Class="FIFP.DashBoard.Views.ShutdownManagement"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"    
    xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"
    xmlns:Presentation="clr-namespace:FIFP.Common.Behaviors.CommonEventArgs;assembly=FIFP.Common"
    xmlns:local="clr-namespace:FIFP.DashBoard.Views"
    xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
    DataContext="{Binding ShutdownMngVM,Source={StaticResource ServiceLocator}}"
    d:DesignHeight="600" d:DesignWidth="1000">

    <UserControl.Resources>
        <DataTemplate x:Key="ManagerTemplate">
            <StackPanel Orientation="Horizontal">
                <TextBlock Text="{Binding UnitName}" />
            </StackPanel>
        </DataTemplate>
    </UserControl.Resources>
    <Grid x:Name="LayoutRoot" Margin="0,5,0,0">

        <Grid Margin="0">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="210"/>
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>

            <Grid Grid.Column="0">
                
                <Grid x:Name="treeViewGrid" Margin="0" VerticalAlignment="Top">
                    <sdk:TreeView Name="treeView" ItemsSource="{Binding TreeViewUnitList}" Margin="0,10,0,0" VerticalAlignment="Top" Style="{StaticResource TreeViewStyleSMUR}">
                        <sdk:TreeView.ItemTemplate>
                            <sdk:HierarchicalDataTemplate ItemsSource="{Binding ChildUnitList}">
                                <StackPanel>
                                    <TextBlock Text="{Binding UnitName}" IsHitTestVisible="{Binding IsNodeEnabled}"></TextBlock>
                                </StackPanel>
                            </sdk:HierarchicalDataTemplate>
                        </sdk:TreeView.ItemTemplate>
                        <i:Interaction.Triggers>
                            <!--<i:EventTrigger EventName="SelectionChanged">
                                <Presentation:InvokeDelegateCommandAction
                                Command="{Binding Source={StaticResource ServiceLocator},Path=ShutdownMngVM.TreeviewSelectionChanged}"
                                CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=InvokeParameter}" />
                            </i:EventTrigger>-->
                            <i:EventTrigger  EventName="SelectedItemChanged">
                                <i:InvokeCommandAction Command="{Binding TreeviewSelectionChanged}" 
        							CommandParameter="{Binding ElementName=treeView}"  />
                            </i:EventTrigger>
                            <!--<i:EventTrigger  EventName="Loaded">
                                <i:InvokeCommandAction Command="{Binding TreeviewLoaded}" 
        							CommandParameter="{Binding ElementName=treeView}"  />
                            </i:EventTrigger>-->
                        </i:Interaction.Triggers>                       
                    </sdk:TreeView>
                </Grid>
            </Grid>

            <Grid Grid.Row="0" Grid.Column="1">
                <Grid.RowDefinitions>
                    <RowDefinition Height="*"></RowDefinition>
                    <RowDefinition Height="10"></RowDefinition>
                    <RowDefinition Height="*"></RowDefinition>
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="*"/>
                    <ColumnDefinition Width="Auto"/>
                    <ColumnDefinition Width="*"/>
                </Grid.ColumnDefinitions>

                <Grid Grid.Row="0" Grid.Column="0" Margin="20,0,20,0">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto"></RowDefinition>
                        <RowDefinition Height="*"></RowDefinition>
                    </Grid.RowDefinitions>
                    <Border BorderThickness="0" Margin="0,0,50,0" Grid.Row="0" Background="#FF303040" BorderBrush="#FF303040">
                        <TextBlock Text="Activities" Foreground="White" FontFamily="Calibri" FontSize="16" HorizontalAlignment="Left"></TextBlock>
                    </Border>

                    <Grid x:Name="activitiesGrid" Grid.Row="1" Margin="0,5,0,10">
                        <sdk:DataGrid x:Name="activitiesOnSelectedUnitGrid" ItemsSource="{Binding ActivityListWithSelectedUnit}" AutoGenerateColumns="False" 
                          Style="{StaticResource DataGridStyle}" RowHeaderStyle="{StaticResource DataGridRowHeaderStyle1}" ColumnHeaderStyle="{StaticResource DataGridColumnHeaderStyle}" RowStyle="{StaticResource DataGridRowStyle}" CellStyle="{StaticResource DataGridCellStyle}" HorizontalScrollBarVisibility="Disabled" IsReadOnly="True">
                            <i:Interaction.Triggers>
                                <i:EventTrigger  EventName="SelectionChanged">
                                    <i:InvokeCommandAction Command="{Binding ActivitySelectChanged}" 
        							CommandParameter="{Binding ElementName=activitiesOnSelectedUnitGrid}"  />
                                </i:EventTrigger>
                            </i:Interaction.Triggers>

                            <sdk:DataGrid.Columns>
                                <sdk:DataGridTextColumn Header="Unit Name" Binding="{Binding UnitName, Mode=OneWay}" MinWidth="90" />
                                <sdk:DataGridTextColumn Header="Activity"  Binding="{Binding ActivityType, Mode=OneWay}" MinWidth="90" />
                                <sdk:DataGridTextColumn Header="Start Date" Binding="{Binding Start, Mode=OneWay, StringFormat=yyyy-MM-dd}" MinWidth="90" />
                                <sdk:DataGridTextColumn Header="End Date" Binding="{Binding End,   Mode=OneWay, StringFormat=yyyy-MM-dd}" MinWidth="90" />
                            </sdk:DataGrid.Columns>

                        </sdk:DataGrid>
                    </Grid>

                </Grid>

                <Grid Grid.Row="0" Grid.Column="1" Margin="0,50,0,0">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto"></RowDefinition>
                        <RowDefinition Height="Auto"></RowDefinition>
                        <RowDefinition Height="*"></RowDefinition>
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto"/>
                        <ColumnDefinition Width="*"/>
                    </Grid.ColumnDefinitions>

                    <Button Name="btnSIMOPS" Content="Apply SIMOPS" IsEnabled="{Binding IsApplySIMOPSEnabled}" Grid.ColumnSpan="2" Margin="0" Style="{StaticResource ButtonStyle}" Width="150" HorizontalAlignment="Right">
                        <i:Interaction.Triggers>
                            <i:EventTrigger  EventName="Click">
                                <i:InvokeCommandAction Command="{Binding SIMOPSClickCommand}" 
        							CommandParameter="{Binding ElementName=btnSIMOPS}"  />
                            </i:EventTrigger>
                        </i:Interaction.Triggers>
                    </Button>
                    <Button Name="btnCrossingLine" Content="Apply Crossing line" IsEnabled="{Binding IsApplyCrossLineEnabled}" Margin="0,5,0,5" Grid.Row="1" Grid.ColumnSpan="2" Style="{StaticResource ButtonStyle}" Width="150" HorizontalAlignment="Right">
                        <i:Interaction.Triggers>
                            <i:EventTrigger  EventName="Click">
                                <i:InvokeCommandAction Command="{Binding CrossingLineClickCommand}" 
        							CommandParameter="{Binding ElementName=btnCrossingLine}"  />
                            </i:EventTrigger>
                        </i:Interaction.Triggers>
                    </Button>
                    <ComboBox x:Name="cmbClosedStrings" IsEnabled="{Binding IsCombinedTowerEnabled}" ItemsSource="{Binding ClosedStringList}" Width="150" SelectedItem="{Binding SelectedClosedString, Mode=TwoWay}"  Margin="0" Grid.Row="2" Grid.ColumnSpan="2" VerticalAlignment="Top" Style="{StaticResource ComboBoxStyleNew}" Height="30" ItemContainerStyle="{StaticResource ComboBoxItemStyle}">
                        <i:Interaction.Triggers>
                            <i:EventTrigger  EventName="SelectionChanged">
                                <i:InvokeCommandAction Command="{Binding ClosedStringSelectionCommand}" 
        							CommandParameter="{Binding ElementName=cmbClosedStrings}"  />
                            </i:EventTrigger>
                        </i:Interaction.Triggers>
                    </ComboBox>
                </Grid>

                <Grid Grid.Row="0" Grid.Column="2" Margin="20,0,10,0">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto"></RowDefinition>
                        <RowDefinition Height="*"></RowDefinition>
                    </Grid.RowDefinitions>
                    <Border BorderThickness="0" Margin="0,0,50,0" Grid.Row="0" Background="#FF303040" BorderBrush="#FF303040">
                        <TextBlock Text="Linked Shutdown" Foreground="White" FontFamily="Calibri" FontSize="16"/>
                    </Border>

                    <Grid x:Name="thirdGrid" Grid.Row="1" Margin="0,5,0,10">

                        <sdk:DataGrid x:Name="linkedShutdownGrid" ItemsSource="{Binding FilteredLinkedShutdownList}" AutoGenerateColumns="False" 
                          Style="{StaticResource DataGridStyle}" ColumnHeaderStyle="{StaticResource DataGridColumnHeaderStyle}" RowStyle="{StaticResource DataGridRowStyle}" CellStyle="{StaticResource DataGridCellStyle}" HorizontalScrollBarVisibility="Disabled" IsReadOnly="True" SelectionChanged="linkedShutdownGrid_SelectionChanged">

                            <sdk:DataGrid.Columns>
                                <sdk:DataGridTextColumn Header="Unit Name" Binding="{Binding UnitName, Mode=TwoWay}"  Width="90"/>
                                <sdk:DataGridTextColumn Header="Start Date" Binding="{Binding Start, Mode=OneWay, StringFormat=yyyy-MM-dd}"  Width="90"/>
                                <sdk:DataGridTextColumn Header="End Date" Binding="{Binding End,   Mode=OneWay, StringFormat=yyyy-MM-dd}"  Width="90"/>
                            </sdk:DataGrid.Columns>

                        </sdk:DataGrid>

                    </Grid>
                </Grid>

                <Path Data="M25.666672,37 L204.34454,37" Margin="20,5,0,0" Grid.Row="1" Grid.ColumnSpan="3" Stretch="Fill" StrokeThickness="1" UseLayoutRounding="False" VerticalAlignment="Top" Height="1" Stroke="{StaticResource LineColor}"/>

                <Grid Margin="20,5,0,0" Grid.Row="2" Grid.ColumnSpan="3">
                    <local:UCAppointment_New x:Name="overlapAppointment" />
                </Grid>

            </Grid>

            

        </Grid>
    </Grid>
</UserControl>
